package com.tobeface.wechat.request.api;

import com.google.common.collect.ImmutableMap;
import com.tobeface.modules.lang.Requires;
import com.tobeface.wechat.request.AbstractWeChatApiRequestBuilder;
import com.tobeface.wechat.request.WeChatRequest;

/**
 * @author loudyn
 */
public class GroupApiRequestBuilder {

    public static final GroupApiRequestBuilder INSTANCE = new GroupApiRequestBuilder();

    /**
     * @return
     */
    public CreateGroupApiRequestBuilder create() {
        return new CreateGroupApiRequestBuilder();
    }

    private GroupApiRequestBuilder() {
    }

    /**
     * @author loudyn
     */
    public class CreateGroupApiRequestBuilder extends AbstractWeChatApiRequestBuilder {

        private String name;

        /**
         *
         */
        CreateGroupApiRequestBuilder() {
            super("https://api.weixin.qq.com/cgi-bin/groups/create", WeChatRequest.Verb.POST);
        }

        /**
         * @param name
         * @return
         */
        public CreateGroupApiRequestBuilder name(String name) {
            Requires.hasText(name, "name must not be empty or null!");
            this.name = name;
            return this;
        }

        @Override
        protected void configRequest(WeChatRequest request) {
            request.entity(ImmutableMap.of("group", ImmutableMap.of("name", name)));
        }
    }
}
